<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Models\SeeSum;
class Scene extends Model {

    protected $table = 'scene';
    protected $guarded = ['id'];

    public function getArea(){
        return $this->hasOne('App\Models\Area','id','area_id');
    }

    public function getSumAttribute(){
        $seeSum = SeeSum::where("scene_id",$this->id)->first();
        if(isset($seeSum)){
            return $seeSum->see_sum;
        }else{
            return 0;
        }
    }
}
